package com.victualler.business.purchase.controller.impl;

import com.victualler.business.purchase.controller.PurchaseOrderController;
import com.victualler.business.purchase.dto.PurchaseOrderInfoDto;
import com.victualler.business.purchase.dto.request.PurchaseRequestDto;
import com.victualler.business.purchase.entity.PurchaseOrderDao;
import com.victualler.business.purchase.repository.PurchaseOrderQueryRepository;
import com.victualler.business.purchase.repository.PurchaseOrderRepository;
import com.victualler.business.purchase.service.PurchaseOrderService;
import com.victualler.core.base.controller.impl.BaseRestControllerImpl;
import com.victualler.core.common.dto.PageDto;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Guoshichang
 * @discription:    
 */
@RestController
@RequestMapping("/business/purchase")
public class PurchaseOrderControllerImpl extends BaseRestControllerImpl<PurchaseOrderDao,PurchaseOrderRepository,PurchaseOrderQueryRepository,PurchaseOrderService> implements PurchaseOrderController {
    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param purchaseRequestDto 请求对象
     * @Function  根据条件入参prePurchaseRequestDto动态分页查询权限
     */
    @RequestMapping("/getByRequestDto")
    public PageDto<PurchaseOrderDao> getByRequestDto(@RequestBody PurchaseRequestDto purchaseRequestDto, @RequestParam("pageNo") int pageNo, @RequestParam("limit") int limit) {
        return this.baseService.getByRequestDto(purchaseRequestDto,pageNo,limit);
    }

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param id 预订单id
     * @Function  根据条件入参prePurchaseRequestDto动态分页查询权限
     */
    @RequestMapping("/findInfo/{id}")
    public PurchaseOrderInfoDto findInfo(@PathVariable("id") Long id) {
        return this.baseService.findInfo(id);
    }

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param purchaseOrderInfoDto 预订单实体大对象
     * @Function  保存预订单实体大对象
     */
    @RequestMapping("/saveInfo")
    public void saveInfo(@RequestBody PurchaseOrderInfoDto purchaseOrderInfoDto) {
        this.baseService.saveInfo(purchaseOrderInfoDto);
    }
}
